summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-02-22 21:23:23 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-02-22 21:23:23 +0000
commitad2bdf9e0f60aaa732011e0bf783fd99258a9f38 (patch)
tree369475d5cfb5ea3068d5379cb3a54934ea0ff1e7
parenta5840a9b10cb2a6be60d5469561dda06acdb0b57 (diff)
downloadATCD-ad2bdf9e0f60aaa732011e0bf783fd99258a9f38.tar.gz
ChangeLogTag: Mon Feb 22 21:20:15 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog17
-rw-r--r--TAO/TAO_IDL/be/be_codegen.cpp74
-rw-r--r--TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp14
-rw-r--r--TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp15
-rw-r--r--TAO/TAO_IDL/be_include/be_codegen.h2
5 files changed, 103 insertions, 19 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index e2be68e1f33..8db85b8ac5f 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,20 @@
+Mon Feb 22 21:20:15 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/be/be_codegen.cpp:
+ * TAO_IDL/be_include/be_codegen.h:
+
+ Added random 6-character string to #ifdef guard generation,
+ to prevent hiding when IDL files have the same name (but
+ are in different directories, the #ifdef guard uses only
+ the local filename).
+
+ * TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp:
+ * TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp:
+
+ Added logic to check for inheritance from DDS_State or
+ DDS_Event connectors, to generate inheritance in the
+ connector impl from the correct Base connector template.
+
Mon Feb 22 13:47:47 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* TAO_IDL/fe/idl.ll:
diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp
index 57ecdd1de21..e1762e4d15e 100644
--- a/TAO/TAO_IDL/be/be_codegen.cpp
+++ b/TAO/TAO_IDL/be/be_codegen.cpp
@@ -20,7 +20,11 @@
#include "global_extern.h"
#include "utl_string.h"
#include "idl_defines.h"
+
#include "ace/OS_NS_ctype.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Numeric_Limits.h"
TAO_CodeGen * tao_cg = 0;
@@ -2216,6 +2220,11 @@ TAO_CodeGen::gen_ifndef_string (const char *fname,
macro_name[i + offset] = '_';
}
}
+
+ ACE_OS::strcat (macro_name, "_XXXXXX");
+ char * const t = ACE_OS::strstr (macro_name, "XXXXXX");
+
+ this->make_rand_extension (t);
ACE_OS::strcat (macro_name, suffix);
@@ -3378,6 +3387,71 @@ TAO_CodeGen::gen_conn_src_includes (void)
}
void
+TAO_CodeGen::make_rand_extension (char * const t)
+{
+ size_t const NUM_CHARS = ACE_OS::strlen (t);
+
+ // Use ACE_Time_Value::msec(ACE_UINT64&) as opposed to
+ // ACE_Time_Value::msec(void) to avoid truncation.
+ ACE_UINT64 msec;
+
+ // Use a const ACE_Time_Value to resolve ambiguity between
+ // ACE_Time_Value::msec (long) and ACE_Time_Value::msec(ACE_UINT64&) const.
+ ACE_Time_Value const now = ACE_OS::gettimeofday ();
+ now.msec (msec);
+
+ // Add the process and thread ids to ensure uniqueness.
+ msec += ACE_OS::getpid ();
+ msec += static_cast<size_t> (ACE_OS::thr_self ());
+
+ // ACE_thread_t may be a char* (returned by ACE_OS::thr_self()) so
+ // we need to use a C-style cast as a catch-all in order to use a
+ // static_cast<> to an integral type.
+ ACE_RANDR_TYPE seed = static_cast<ACE_RANDR_TYPE> (msec);
+
+ // We only care about UTF-8 / ASCII characters in generated
+ // filenames. A UTF-16 or UTF-32 character could potentially cause
+ // a very large space to be searched in the below do/while() loop,
+ // greatly slowing down this mkstemp() implementation. It is more
+ // practical to limit the search space to UTF-8 / ASCII characters
+ // (i.e. 127 characters).
+ //
+ // Note that we can't make this constant static since the compiler
+ // may not inline the return value of ACE_Numeric_Limits::max(),
+ // meaning multiple threads could potentially initialize this value
+ // in parallel.
+ float const MAX_VAL =
+ static_cast<float> (ACE_Numeric_Limits<char>::max ());
+
+ // Use high-order bits rather than low-order ones (e.g. rand() %
+ // MAX_VAL). See Numerical Recipes in C: The Art of Scientific
+ // Computing (William H. Press, Brian P. Flannery, Saul
+ // A. Teukolsky, William T. Vetterling; New York: Cambridge
+ // University Press, 1992 (2nd ed., p. 277).
+ //
+ // e.g.: MAX_VAL * rand() / (RAND_MAX + 1.0)
+
+ // Factor out the constant coefficient.
+ float const coefficient =
+ static_cast<float> (MAX_VAL / (RAND_MAX + 1.0f));
+
+ for (unsigned int n = 0; n < NUM_CHARS; ++n)
+ {
+ ACE_TCHAR r;
+
+ // This do/while() loop allows this alphanumeric character
+ // selection to work for EBCDIC, as well.
+ do
+ {
+ r = static_cast<ACE_TCHAR> (coefficient * ACE_OS::rand_r (seed));
+ }
+ while (!ACE_OS::ace_isalnum (r));
+
+ t[n] = static_cast<char> (ACE_OS::ace_toupper (r));
+ }
+}
+
+void
TAO_CodeGen::destroy (void)
{
delete this->client_header_;
diff --git a/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp b/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp
index 2c48a0a2e81..0fd991f105a 100644
--- a/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exh.cpp
@@ -73,18 +73,14 @@ be_visitor_connector_dds_exh::visit_connector (be_connector *node)
return 0;
}
+ /// Assumes parent connector exists and is either DDS_State
+ /// or DDS_Event, so we generate inheritance from the
+ /// corresponding template. May have to generalize this logic.
os_ << be_nl << be_nl
<< "class " << this->export_macro_.c_str () << " "
<< this->node_->local_name () << "_exec_i" << be_idt_nl
- << ": public ";
-
- // Placeholder for forthcoming real-world logic.
- bool dds_event_connector = true;
-
- if (dds_event_connector)
- {
- os_ << "DDS_Event_Connector_T";
- }
+ << ": public " << node->base_connector ()->local_name ()
+ << "_Connector_T";
AST_Decl **datatype = 0;
int status = this->t_args_->get (datatype, 0UL);
diff --git a/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp b/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp
index 10b199626ef..6f4268f5f7f 100644
--- a/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_connector/connector_dds_exs.cpp
@@ -69,10 +69,8 @@ be_visitor_connector_dds_exs::visit_connector (be_connector *node)
<< this->node_->local_name () << "_exec_i::"
<< this->node_->local_name () << "_exec_i (void)"
<< be_idt_nl
- << ": ";
-
- // Placeholder for forthcoming real-world logic.
- bool dds_event_connector = true;
+ << ": " << node->base_connector ()->local_name ()
+ << "_Connector_T";
AST_Decl **datatype = 0;
int status = this->t_args_->get (datatype, 0UL);
@@ -89,12 +87,9 @@ be_visitor_connector_dds_exs::visit_connector (be_connector *node)
AST_Type *ut = AST_Type::narrow_from_decl (*datatype);
-
- if (dds_event_connector)
- {
- os_ << "DDS_Event_Connector_T";
- }
-
+ /// Assumes parent connector exists and is either DDS_State
+ /// or DDS_Event, so we generate inheritance from the
+ /// corresponding template. May have to generalize this logic.
os_ << " <" << be_idt << be_idt_nl
<< this->dds_traits_name_.c_str () << "," << be_nl
<< "DDS" << this->node_->local_name () << "_Traits," << be_nl;
diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h
index 6dff10e6ac9..fc8cb68c16c 100644
--- a/TAO/TAO_IDL/be_include/be_codegen.h
+++ b/TAO/TAO_IDL/be_include/be_codegen.h
@@ -471,6 +471,8 @@ private:
const char *macro,
const char *msg,
bool for_skel = false);
+
+ void make_rand_extension (char * const t);
private:
/// Client header stream.