ACE_Function_Node Class Reference

Keeps track of the symbol name of for a shared function. More...

#include <Parse_Node.h>

Inheritance diagram for ACE_Function_Node:

Inheritance graph
[legend]
Collaboration diagram for ACE_Function_Node:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Function_Node (const ACE_TCHAR *pathname, const ACE_TCHAR *func_name)
virtual void * symbol (ACE_Service_Gestalt *config, int &yyerrno, ACE_Service_Object_Exterminator *gobbler=0)
virtual ~ACE_Function_Node (void)
void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Member Functions

ACE_TCHARmake_func_name (ACE_TCHAR const *func_name)
 ACE_Function_Node (const ACE_Function_Node &)
ACE_Function_Nodeoperator= (const ACE_Function_Node &)

Private Attributes

const ACE_TCHARfunction_name_
 Name of the function that we're parsing.


Detailed Description

Keeps track of the symbol name of for a shared function.

Note:
This class is only meant for INTERNAL use by ACE.

For internal use only.

Definition at line 398 of file Parse_Node.h.


Constructor & Destructor Documentation

ACE_Function_Node::ACE_Function_Node const ACE_TCHAR pathname,
const ACE_TCHAR func_name
 

Definition at line 508 of file Parse_Node.cpp.

References ACE_TCHAR, ACE_TRACE, and ACE_Location_Node::pathname().

00510   : function_name_ (make_func_name (func_name))
00511 {
00512   ACE_TRACE ("ACE_Function_Node::ACE_Function_Node");
00513   this->pathname (ACE::strnew (path));
00514   this->must_delete_ = 1;
00515 }

ACE_Function_Node::~ACE_Function_Node void   )  [virtual]
 

Definition at line 633 of file Parse_Node.cpp.

References ACE_TRACE, and function_name_.

00634 {
00635   ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
00636   delete[] const_cast<ACE_TCHAR *> (function_name_);
00637   delete[] const_cast<ACE_TCHAR *> (pathname_);
00638 }

ACE_Function_Node::ACE_Function_Node const ACE_Function_Node  )  [private]
 


Member Function Documentation

void ACE_Function_Node::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Location_Node.

Definition at line 501 of file Parse_Node.cpp.

References ACE_TRACE.

00502 {
00503 #if defined (ACE_HAS_DUMP)
00504   ACE_TRACE ("ACE_Function_Node::dump");
00505 #endif /* ACE_HAS_DUMP */
00506 }

ACE_TCHAR * ACE_Function_Node::make_func_name ACE_TCHAR const *  func_name  )  [private]
 

This function embeds the ACE versioned namespace name into the original function name if versioned namespace support has been enabled and the original function name conforms to the ACE Service Object factory function naming conventions. For example "@c _make_Foo" becomes "@c make_ACE_5_4_7_Foo".

If versioned namespace support is disabled or the factory function name does conform to ACE conventions, no mangling will occur and the verbatim function name is returned.
Returns:
Function name that takes into account versioned namespace name. Caller is responsible for calling operator delete[] or ACE::strdelete() on the returned string.

Definition at line 518 of file Parse_Node.cpp.

References ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_Auto_Basic_Array_Ptr< X >::release(), ACE_OS::snprintf(), ACE_OS::strlen(), ACE_OS::strncmp(), and ACE::strnew().

00519 {
00520   // Preprocessor symbols will not be expanded if they are
00521   // stringified.  Force the preprocessor to expand them during the
00522   // argument prescan by calling a macro that itself calls another
00523   // that performs the actual stringification.
00524 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
00525 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME) #NAME
00526 # define ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(NAME) ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING_IMPL(NAME)
00527 # define ACE_VERSIONED_NAMESPACE_NAME_STRING ACE_MAKE_VERSIONED_NAMESPACE_NAME_STRING(ACE_VERSIONED_NAMESPACE_NAME)
00528 
00529   // Check if function is using the ACE naming convention.  If so,
00530   // it is likely that the ACE factory function macros
00531   // (e.g. ACE_FACTORY_DECLARE) were used to declare and define it, so
00532   // mangle the function name to include the ACE versioned namespace
00533   // name as is done in the ACE macros.  Otherwise, leave the function
00534   // name as is.
00535 
00536   static ACE_TCHAR const make_prefix[] = ACE_LIB_TEXT ("_make_");
00537   static size_t const make_prefix_len =
00538     sizeof (make_prefix) / sizeof (make_prefix[0]) - 1;
00539 
00540   if (ACE_OS::strncmp (make_prefix, func_name, make_prefix_len) == 0)
00541     {
00542       static ACE_TCHAR const versioned_namespace_name[] =
00543         ACE_LIB_TEXT (ACE_VERSIONED_NAMESPACE_NAME_STRING) ACE_LIB_TEXT("_") ;
00544 
00545       // Null terminator included in versioned_namespace_name_len since
00546       // it is static constant.
00547       static size_t const versioned_namespace_name_len =
00548         sizeof (versioned_namespace_name)
00549         / sizeof (versioned_namespace_name[0]); // - 1;
00550 
00551       size_t const len =
00552         ACE_OS::strlen (func_name)
00553         + versioned_namespace_name_len;
00554       // + 1;  // Null terminator.
00555 
00556       ACE_TCHAR * mangled_func_name;
00557       ACE_NEW_RETURN (mangled_func_name,
00558                       ACE_TCHAR[len],
00559                       0);
00560 
00561       ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe (mangled_func_name);
00562 
00563       ACE_OS::snprintf (mangled_func_name,
00564                         len,
00565                         ACE_LIB_TEXT ("%s%s%s"),
00566                         make_prefix,
00567                         versioned_namespace_name,
00568                         func_name + make_prefix_len);
00569 
00570       return safe.release ();
00571     }
00572 #endif  /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
00573 
00574   return ACE::strnew (func_name);
00575 }

ACE_Function_Node& ACE_Function_Node::operator= const ACE_Function_Node  )  [private]
 

void * ACE_Function_Node::symbol ACE_Service_Gestalt config,
int &  yyerrno,
ACE_Service_Object_Exterminator gobbler = 0
[virtual]
 

Will update the yyerrno member and/or corresponding configuration repository

Implements ACE_Location_Node.

Definition at line 578 of file Parse_Node.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_Service_Object_Exterminator, ACE_TCHAR, ACE_TRACE, ACE_DLL::error(), function_name_, LM_ERROR, ACE_Location_Node::open_dll(), and ACE_DLL::symbol().

00581 {
00582   typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
00583     (ACE_Service_Object_Exterminator *);
00584 
00585   ACE_TRACE ("ACE_Function_Node::symbol");
00586   if (this->open_dll (yyerrno) == 0)
00587     {
00588       ACE_Service_Factory_Ptr func = 0;
00589       this->symbol_ = 0;
00590 
00591       // Locate the factory function <function_name> in the shared
00592       // object.
00593       ACE_TCHAR *function_name = const_cast<ACE_TCHAR *> (this->function_name_);
00594       void *func_p = this->dll_.symbol (function_name);
00595       if (func_p == 0)
00596         {
00597           ++yyerrno;
00598 
00599           if (this->symbol_ == 0)
00600             {
00601               ++yyerrno;
00602 
00603 #ifndef ACE_NLOGGING
00604               ACE_TCHAR *errmsg = this->dll_.error ();
00605               ACE_ERROR ((LM_ERROR,
00606                           ACE_LIB_TEXT ("DLL::symbol failed for function %s: ")
00607                           ACE_LIB_TEXT ("%s\n"),
00608                           function_name,
00609                           errmsg ? errmsg :
00610         ACE_LIB_TEXT ("no error reported")));
00611 #endif /* ACE_NLOGGING */
00612 
00613               return 0;
00614             }
00615         }
00616       ptrdiff_t temp_p = reinterpret_cast<ptrdiff_t> (func_p);
00617       func = reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);
00618       // Invoke the factory function and record it's return value.
00619       this->symbol_ = (*func) (gobbler);
00620 
00621       if (this->symbol_ == 0)
00622         {
00623           ++yyerrno;
00624           ACE_ERROR_RETURN ((LM_ERROR,
00625                              ACE_LIB_TEXT ("%p\n"),
00626                              this->function_name_),
00627                             0);
00628         }
00629     }
00630   return this->symbol_;
00631 }


Member Data Documentation

ACE_Function_Node::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Location_Node.

Definition at line 411 of file Parse_Node.h.

const ACE_TCHAR* ACE_Function_Node::function_name_ [private]
 

Name of the function that we're parsing.

Definition at line 437 of file Parse_Node.h.

Referenced by symbol(), and ~ACE_Function_Node().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:22:28 2006 for ACE by doxygen 1.3.6