diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-26 20:12:02 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-26 20:12:02 +0000 |
commit | 916b7d525b204241cc48471fe97a9eec0595831e (patch) | |
tree | 9734e9a37bf58dc722a1dfaa9095e59b772dd384 /TAO | |
parent | 1e368d765519a090a42cb3ebd40886cc0774ae0b (diff) | |
download | ATCD-916b7d525b204241cc48471fe97a9eec0595831e.tar.gz |
Thu Mar 26 14:13:02 1998 Michael Kircher <mk1@cs.wustl.edu>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/AnyAnalyser.cpp | 61 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/AnyAnalyser.h | 3 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/PrintVisitor.cpp | 2 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/TestClient.dsp | 28 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/any_test_i.cpp | 17 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/clnt.cpp | 12 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/clnt.h | 1 |
7 files changed, 94 insertions, 30 deletions
diff --git a/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.cpp b/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.cpp index 2424e2a4c15..ade413e945a 100644 --- a/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.cpp +++ b/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.cpp @@ -16,6 +16,7 @@ // ============================================================================ #include "AnyAnalyser.h" +#include "tao/Align.h" AnyAnalyser::AnyAnalyser (const char *file_name) : printVisitor_ptr_(new PrintVisitor (file_name)) { @@ -32,9 +33,11 @@ AnyAnalyser::printAny (CORBA::Any any) { 0, // member count 0}; // recursion level + unsigned char *value_ptr_ = (unsigned char *)any.value (); + // analyse the any Node *node_ptr_ = analyse (any.type (), - (unsigned char *)value_ptr, + value_ptr_, recurseInfo_); // print the results @@ -46,7 +49,10 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, unsigned char *&value_ptr, RecurseInfo ri) { - + CORBA::Long size, alignment, align_offset; + CORBA::TypeCode_ptr param; + unsigned char *start_addr = value_ptr; + TAO_TRY { Node *node_ptr_ = 0; @@ -55,9 +61,11 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, switch (tc_ptr->kind(TAO_TRY_ENV)) { case CORBA::tk_struct: - cout << "Struct detected" << endl; - { - // create a new Node + { + // to hold a pointer to the start of the struct + unsigned char *start_addr = value_ptr; + + // create a new Node StructNode *structNode_ptr_ = new StructNode (tc_ptr->name (TAO_TRY_ENV), ri.recursion_level); @@ -69,8 +77,37 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, tc_ptr, // parent typecode i, // member count ri.recursion_level+1}; - - structNode_ptr_->addChild (analyse (tc_ptr->member_type (i, TAO_TRY_ENV), + + + // get the type code of the child i + param = tc_ptr->member_type (i, TAO_TRY_ENV); + TAO_CHECK_ENV; + + // get the size + size = param->size (TAO_TRY_ENV); + TAO_CHECK_ENV; + + // get the alignment + alignment = param->alignment (TAO_TRY_ENV); + TAO_CHECK_ENV; + + // calculate + align_offset = + (ptr_arith_t) ptr_align_binary (value_ptr, alignment) + - (ptr_arith_t) value_ptr + + (ptr_arith_t) ptr_align_binary (start_addr, alignment) + - (ptr_arith_t) start_addr; + TAO_CHECK_ENV; + + // if both the start_addr and data are not aligned as per + // the alignment, we do not add the offset + value_ptr = (unsigned char *) ((ptr_arith_t) value_ptr + + ((align_offset == alignment) ? + 0 : align_offset)); + + printf ("%d\n", (unsigned long)value_ptr); + + structNode_ptr_->addChild (analyse (param, value_ptr, recurseInfo_)); } @@ -80,7 +117,7 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, case CORBA::tk_double: if (ri.kind == PARENT_IS_STRUCT) { - node_ptr_ = (Node *) new DoubleNode ((CORBA::Double *)*value_ptr, + node_ptr_ = (Node *) new DoubleNode ((CORBA::Double *)value_ptr, ri.parent_tc_ptr->member_name(ri.member_number, TAO_TRY_ENV), ri.recursion_level); @@ -91,7 +128,6 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, ri.recursion_level); } value_ptr += 8; - cout << "Double detected" << endl; break; case CORBA::tk_long: @@ -107,10 +143,13 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, ri.recursion_level); } value_ptr += 4; - cout << "Long detected" << endl; break; case CORBA::tk_ulong: + cout << "Name:" << ri.parent_tc_ptr->member_name(ri.member_number,TAO_TRY_ENV) + << " Value: " << (CORBA::ULong)*value_ptr << endl; + printf ("%X\n", (unsigned long)value_ptr); + if (ri.kind == PARENT_IS_STRUCT) { node_ptr_ = (Node *) new ULongNode ((CORBA::ULong *)value_ptr, ri.parent_tc_ptr->member_name(ri.member_number, @@ -123,7 +162,6 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, ri.recursion_level); } value_ptr += 4; - cout << "ULong detected" << endl; break; case CORBA::tk_string: @@ -139,7 +177,6 @@ AnyAnalyser::analyse (CORBA::TypeCode_ptr tc_ptr, ri.recursion_level); } value_ptr += 4; - cout << "String detected" << endl; break; default: ACE_ERROR ((LM_ERROR, "AnyAnalyser::analyse: No known kind of type detected!\n")); diff --git a/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.h b/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.h index 8a4095bc991..5dbeb981282 100644 --- a/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.h +++ b/TAO/examples/Simulator/DOVEMIB/AnyAnalyser.h @@ -50,4 +50,5 @@ private: PrintVisitor *printVisitor_ptr_; }; -#endif
\ No newline at end of file +#endif + diff --git a/TAO/examples/Simulator/DOVEMIB/PrintVisitor.cpp b/TAO/examples/Simulator/DOVEMIB/PrintVisitor.cpp index 17eb070ec8e..a76ba7cfa2e 100644 --- a/TAO/examples/Simulator/DOVEMIB/PrintVisitor.cpp +++ b/TAO/examples/Simulator/DOVEMIB/PrintVisitor.cpp @@ -75,7 +75,7 @@ PrintVisitor::visitULongNode (ULongNode *uLongNode) { void PrintVisitor::visitStringNode (StringNode *stringNode) { printPadding (stringNode->getRecursionLevel()); - fprintf (output_, "CORBA::String %s = %s;", stringNode->getName(), (char *)stringNode->getValue()); + fprintf (output_, "CORBA::String %s = \"%s\";", stringNode->getName(), (char *)stringNode->getValue()); } void diff --git a/TAO/examples/Simulator/DOVEMIB/TestClient.dsp b/TAO/examples/Simulator/DOVEMIB/TestClient.dsp index 7a51062af19..7d412b2290b 100644 --- a/TAO/examples/Simulator/DOVEMIB/TestClient.dsp +++ b/TAO/examples/Simulator/DOVEMIB/TestClient.dsp @@ -84,6 +84,34 @@ LINK32=link.exe # Name "TestClient - Win32 Debug"
# Begin Source File
+SOURCE=.\any_test.idl
+
+!IF "$(CFG)" == "TestClient - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TestClient - Win32 Debug"
+
+# Begin Custom Build - Invoking TAO_IDL compiler
+InputPath=.\any_test.idl
+InputName=any_test
+
+BuildCmds= \
+ ..\..\..\..\tao_idl\tao_idl $(InputName).idl
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\any_testC.cpp
# End Source File
# Begin Source File
diff --git a/TAO/examples/Simulator/DOVEMIB/any_test_i.cpp b/TAO/examples/Simulator/DOVEMIB/any_test_i.cpp index 358dd2c7029..1f94919e1a2 100644 --- a/TAO/examples/Simulator/DOVEMIB/any_test_i.cpp +++ b/TAO/examples/Simulator/DOVEMIB/any_test_i.cpp @@ -39,15 +39,14 @@ Any_Test_i::try_an_any (const CORBA::Any &a, CORBA::Environment &env) AnyAnalyser anyAnalyser_ = AnyAnalyser ("stdout"); TAO_CHECK_ENV; - - Weapons *weapons_ = (Weapons *)a.value(); - - cout << "Adr weapon5 status:" << &(weapons_->weapon5_status) << endl; - cout << "Adr first double: " << &(weapons_->utilization) << endl; - cout << "Adr first double: " << &(weapons_->overhead) << endl; - cout << "Adr util: " << &(weapons_->utilization) << endl; - cout << "utilization: " << weapons_->utilization << endl; - cout << "ArrTime: " << weapons_->arrival_time << endl; + Weapons *weapons_ = 0; + if (a.type()->equal(_tc_Weapons,TAO_TRY_ENV)) { + + weapons_ = (Weapons *)a.value(); + cout << "ID: " << a.type()->id(TAO_TRY_ENV) << endl; + cout << "CompTime: " << weapons_->computation_time << endl; + cout << "Adr CompTime: " << &(weapons_->computation_time) << endl; + } anyAnalyser_.printAny (a); } diff --git a/TAO/examples/Simulator/DOVEMIB/clnt.cpp b/TAO/examples/Simulator/DOVEMIB/clnt.cpp index 7f97b2c3ee1..eed0372c3d6 100644 --- a/TAO/examples/Simulator/DOVEMIB/clnt.cpp +++ b/TAO/examples/Simulator/DOVEMIB/clnt.cpp @@ -96,26 +96,26 @@ Any_Test_Client::run () data.replace (_tc_Navigation, &navigation_, CORBA::B_FALSE, TAO_TRY_ENV); ACE_DEBUG ((LM_DEBUG,"Starting test with Any: Navigation\n")); - // any_test_ptr_->try_an_any (data, TAO_TRY_ENV); + any_test_ptr_->try_an_any (data, TAO_TRY_ENV); ACE_DEBUG ((LM_DEBUG,"Ending test with Any: Navigation\n")); weapons_.number_of_weapons = 5; weapons_.weapon1_identifier = CORBA::string_alloc (20); strcpy (weapons_.weapon1_identifier, "A"); - weapons_.weapon1_status = 0; + weapons_.weapon1_status = 1; weapons_.weapon2_identifier = CORBA::string_alloc (20); strcpy (weapons_.weapon2_identifier, "B"); - weapons_.weapon2_status = 0; + weapons_.weapon2_status = 2; weapons_.weapon3_identifier = CORBA::string_alloc (20); strcpy (weapons_.weapon3_identifier, "C"); - weapons_.weapon3_status = 0; + weapons_.weapon3_status = 4; weapons_.weapon4_identifier = CORBA::string_alloc (20); strcpy (weapons_.weapon4_identifier, "D"); - weapons_.weapon4_status = 0; + weapons_.weapon4_status = 8; weapons_.weapon5_identifier = CORBA::string_alloc (20); strcpy (weapons_.weapon5_identifier, "E"); - weapons_.weapon5_status = 0; + weapons_.weapon5_status = 16; weapons_.utilization = 1; weapons_.overhead = 2; diff --git a/TAO/examples/Simulator/DOVEMIB/clnt.h b/TAO/examples/Simulator/DOVEMIB/clnt.h index 95f50847506..67ed5c84d57 100644 --- a/TAO/examples/Simulator/DOVEMIB/clnt.h +++ b/TAO/examples/Simulator/DOVEMIB/clnt.h @@ -18,7 +18,6 @@ #include "ace/Get_Opt.h" #include "tao/corba.h" #include "any_testC.h" -//#include "reverseC.h" #include "NavWeapC.h" class Any_Test_Client |