[omniORB] omniidl2 tyepdef bug??

Paul Nader naderp@aals27.alcatel.com.au
Tue, 27 Oct 1998 16:58:43 +1100


----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 78

Sai-Lai,

There seems to be a problem when compiling an idl file with multiple typedefs
to the same type, as in :

typedef sequence<octet> sequence1;
typedef sequence<octet> sequence2;


The compiler will generate distinct typecodes for each sequence in the skeleton
file each guarded by #ifdefs based on the new type name (which is correct) :

...

#ifndef __01RL__tc_sequence1__
#define __01RL__tc_sequence1__

static CORBA::TypeCode _01RL__tc_sequence1("IDL:sequence1:1.0", "sequence1", CORBA::TypeCode(CORBA::tk_sequence, 0, CORBA::TypeCode(CORBA::tk_octet,0)));

#endif

const CORBA::TypeCode_ptr _tc_sequence1 = & _01RL__tc_sequence1;

#ifndef __01RL__tc_sequence2__
#define __01RL__tc_sequence2__

static CORBA::TypeCode _01RL__tc_sequence2("IDL:sequence2:1.0", "sequence2", CORBA::TypeCode(CORBA::tk_sequence, 0, CORBA::TypeCode(CORBA::tk_octet,0)));

#endif

const CORBA::TypeCode_ptr _tc_sequence2 = & _01RL__tc_sequence2;



However, the any inserter and extractors in the header file are guarded by #ifdefs
based on the originating type (i.e sequence<octet>) :

...


#ifndef __04RL__IDL_SEQUENCE_CORBA_Octet__
#define __04RL__IDL_SEQUENCE_CORBA_Octet__

inline void operator<<=(CORBA::Any& _a, const sequence1& _s) {
  MemBufferedStream _0RL_mbuf;
  _tc_sequence1->NP_fillInit(_0RL_mbuf);
  _s >>= _0RL_mbuf;
  _a.NP_replaceData(_tc_sequence1,_0RL_mbuf);
}

...


#endif

#ifndef __04RL__IDL_SEQUENCE_CORBA_Octet__
#define __04RL__IDL_SEQUENCE_CORBA_Octet__

inline void operator<<=(CORBA::Any& _a, const sequence2& _s) {
  MemBufferedStream _0RL_mbuf;
  _tc_sequence2->NP_fillInit(_0RL_mbuf);
  _s >>= _0RL_mbuf;
  _a.NP_replaceData(_tc_sequence2,_0RL_mbuf);
}

...

#endif
...


This causes the compiler to never see the definitions for sequence2, which
has the consequence that if either type is inserted in an any it will always
use the typecode for sequence1.

Shouldn't the #ifdef guards in the header file be based on the new data types??

Regards, Paul.
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: typedef.idl
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 2

typedef sequence<octet> sequence1;
typedef sequence<octet> sequence2;
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: typedef.hh
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 125

#ifndef __typedef_hh__
#define __typedef_hh__

#ifndef USE_omniORB_logStream
#define USE_omniORB_logStream
#endif

#ifndef __CORBA_H_EXTERNAL_GUARD__
#define __CORBA_H_EXTERNAL_GUARD__
#include <omniORB2/CORBA.h>
#endif


#ifdef _LC_attr
#error "A local CPP macro _LC_attr has already been defined."
#else
#ifdef  USE_stub_in_nt_dll
#define _LC_attr _OMNIORB_NTDLL_IMPORT
#else
#define _LC_attr
#endif
#endif

_CORBA_GLOBAL_VAR const CORBA::TypeCode_ptr _tc_sequence1;
typedef _CORBA_Unbounded_Sequence__Octet sequence1;
typedef _CORBA_Sequence_Var<sequence1, CORBA::Octet > sequence1_var;

_CORBA_GLOBAL_VAR const CORBA::TypeCode_ptr _tc_sequence2;
typedef _CORBA_Unbounded_Sequence__Octet sequence2;
typedef _CORBA_Sequence_Var<sequence2, CORBA::Octet > sequence2_var;

#ifndef __04RL__IDL_SEQUENCE_CORBA_Octet__
#define __04RL__IDL_SEQUENCE_CORBA_Octet__

inline void operator<<=(CORBA::Any& _a, const sequence1& _s) {
  MemBufferedStream _0RL_mbuf;
  _tc_sequence1->NP_fillInit(_0RL_mbuf);
  _s >>= _0RL_mbuf;
  _a.NP_replaceData(_tc_sequence1,_0RL_mbuf);
}

inline void operator<<=(CORBA::Any& _a, sequence1* _sp) {
  _a <<= *_sp;
  delete _sp;
}

inline void _03RL_sequence1_delete(void* _data) {
  sequence1* _0RL_t = (sequence1*) _data;
  delete _0RL_t;
}

inline CORBA::Boolean operator>>=(const CORBA::Any& _a, sequence1*& _sp) {
  CORBA::TypeCode_var _0RL_any_tc = _a.type();
  if (!_0RL_any_tc->NP_expandEqual(_tc_sequence1,1)) {
    _sp = 0;
    return 0;
  }
  else {
    void* _0RL_data = _a.NP_data();

    if (!_0RL_data) {
      MemBufferedStream _0RL_tmp_mbuf;
      _a.NP_getBuffer(_0RL_tmp_mbuf);
      sequence1* _0RL_tmp = new sequence1;
      *_0RL_tmp <<= _0RL_tmp_mbuf;
      _0RL_data = (void*) _0RL_tmp;
      _a.NP_holdData(_0RL_data,_03RL_sequence1_delete);
    }

    _sp = (sequence1*) _0RL_data;
    return 1;
  }
}

#endif

#ifndef __04RL__IDL_SEQUENCE_CORBA_Octet__
#define __04RL__IDL_SEQUENCE_CORBA_Octet__

inline void operator<<=(CORBA::Any& _a, const sequence2& _s) {
  MemBufferedStream _0RL_mbuf;
  _tc_sequence2->NP_fillInit(_0RL_mbuf);
  _s >>= _0RL_mbuf;
  _a.NP_replaceData(_tc_sequence2,_0RL_mbuf);
}

inline void operator<<=(CORBA::Any& _a, sequence2* _sp) {
  _a <<= *_sp;
  delete _sp;
}

inline void _03RL_sequence2_delete(void* _data) {
  sequence2* _0RL_t = (sequence2*) _data;
  delete _0RL_t;
}

inline CORBA::Boolean operator>>=(const CORBA::Any& _a, sequence2*& _sp) {
  CORBA::TypeCode_var _0RL_any_tc = _a.type();
  if (!_0RL_any_tc->NP_expandEqual(_tc_sequence2,1)) {
    _sp = 0;
    return 0;
  }
  else {
    void* _0RL_data = _a.NP_data();

    if (!_0RL_data) {
      MemBufferedStream _0RL_tmp_mbuf;
      _a.NP_getBuffer(_0RL_tmp_mbuf);
      sequence2* _0RL_tmp = new sequence2;
      *_0RL_tmp <<= _0RL_tmp_mbuf;
      _0RL_data = (void*) _0RL_tmp;
      _a.NP_holdData(_0RL_data,_03RL_sequence2_delete);
    }

    _sp = (sequence2*) _0RL_data;
    return 1;
  }
}

#endif


#undef _LC_attr

#endif // __typedef_hh__
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: typedefSK.cc
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 24

#include "typedef.hh"


static const char* _0RL_library_version = omniORB_2_6;


#ifndef __01RL__tc_sequence1__
#define __01RL__tc_sequence1__

static CORBA::TypeCode _01RL__tc_sequence1("IDL:sequence1:1.0", "sequence1", CORBA::TypeCode(CORBA::tk_sequence, 0, CORBA::TypeCode(CORBA::tk_octet,0)));

#endif

const CORBA::TypeCode_ptr _tc_sequence1 = & _01RL__tc_sequence1;

#ifndef __01RL__tc_sequence2__
#define __01RL__tc_sequence2__

static CORBA::TypeCode _01RL__tc_sequence2("IDL:sequence2:1.0", "sequence2", CORBA::TypeCode(CORBA::tk_sequence, 0, CORBA::TypeCode(CORBA::tk_octet,0)));

#endif

const CORBA::TypeCode_ptr _tc_sequence2 = & _01RL__tc_sequence2;